<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="renderer" content="webkit">
    <title></title>
    <link rel="stylesheet" href="__ADMIN__/css/pintuer.css">
    <link rel="stylesheet" href="__ADMIN__/css/admin.css">
    <link rel="stylesheet" type="text/css" href="/admins/webuploader.css" />
    <link rel="stylesheet" type="text/css" href="/admins/bootstrap.min.css">
    <script src="__ADMIN__/js/jquery.js"></script>
    <script src="__ADMIN__/js/pintuer.js"></script>
    <script type="text/javascript" src="/admins/webuploader.js"></script>
    <script type="text/javascript" src="/admins/js/jquery.js"></script>
    <script type="text/javascript" src="/admins/assets/js/jquery.min.js"></script>
</head>
<body>
<div class="panel admin-panel">
    <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>修改课件</strong></div>
    <div class="body-content">
        <form method="post" class="form-x" action="" enctype="multipart/form-data">
            <input type="hidden" name="id" value="{$res.id}">
            <div class="form-group">
                <div class="label">
                    <label>上级分类：</label>
                </div>
                <div class="field">
                    <select name="pid" class="input w50">
                        <option value="0">顶级分类</option>
                        {volist name="info" id="vo"}
                        <option {if condition="$res['pid'] eq $vo['id']"}selected="selected"{/if} value="{$vo.id}">{if condition="$vo['level'] neq 0"}|{/if}<?php echo str_repeat('-',$vo['level']*8)?>{$vo.name}</option>
                        {/volist}
                    </select>
                    <div class="tips"></div>
                </div>
            </div>

            <div class="form-group">
                <div class="label">
                    <label>课件名称：</label>
                </div>
                <div class="field">
                    <input type="text" class="input w50" value="{$res.name}" name="name" />
                    <div class="tips"></div>
                </div>
            </div>
            <div class="form-group">
                <div class="label">
                    <label></label>
                </div>
                <div class="field">
                    <button class="button bg-main icon-check-square-o" type="submit"> 提交</button>
                </div>
            </div>
        </form>
    </div>
</div>

</body>
</html>
<script>
    function uuid() {
        var s = [];
        var hexDigits = "0123456789abcdef";
        for (var i = 0; i < 32; i++) {
            s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
        }
        s[14] = "4";  // bits 12-15 of the time_hi_and_version field to 0010
        s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1);  // bits 6-7 of the clock_seq_hi_and_reserved to 01

        var uuid = s.join("");
        return uuid;
    }

</script>
<script type="text/javascript">
    var uploader = WebUploader.create({
        // 选完文件后，是否自动上传。
        auto: true,

        // swf文件路径
        swf:'/admins/Uploader.swf',

        // 文件接收服务端。
        server: '{:url("admin/video/upload")}',
        chunked:true,
        chunkSize:5*1024*1024,

        // 选择文件的按钮。可选。
        // 内部根据当前运行是创建，可能是input元素，也可能是flash.
        pick: '#filePicker',

        accept: {
            title: 'Video',
            extensions: 'mp4',
            mimeTypes: 'video/*'
        }
    });

    // 当有文件被添加进队列的时候
    // uploader.on( 'fileQueued', function( file ) {
    //     $list.append( '<div id="' + file.id + '" class="item">' +
    //         '<h4 class="info">' + file.name + '</h4>' +
    //         '<p class="state">等待上传...</p>' +
    //         '</div>' );
    // });



    uploader.on('uploadStart',function(file){
        var index1 = file.name.lastIndexOf(".");
        var index2 = file.name.length;
        var ext = file.name.substring(index1,index2);
        file.name = uuid()+ext;
    });

    // 文件上传过程中创建进度条实时显示。
    uploader.on( 'uploadProgress', function( file, percentage ) {

        $('.model>p').html(parseInt(percentage*100)+'%')
        $('.model').show();
        if(percentage==1){
            $('.model').hide();
        }
    });

    uploader.on('uploadSuccess',function(file,response){

        var str= "<input type='hidden' name='video' value="+response.filePath+" />"
        $(str).appendTo('.form-x');
        $('#video_comp').css('visibility','visible');
    });

    uploader.on('uploadError',function(file,reason){
        laye.alert('文件上传失败,请刷新页面再试!',{title: '提示框',icon:2,});
    });

</script>
<style type="text/css">
    .model{
        display:none;
        width:100%;
        height:100vh;
        background:#ccc;
        opacity: 0.6;
        text-align:center;
        z-index:100;
        position:fixed;
        top:0;
        left:0;
    }
    .model>img{
        display:block;
        width:70px;
        height:70px;
        margin:0 auto;
        margin-top:20%;
    }
</style>
<div class="model">
    <img src="/admins/images/timg.gif" />
    <p></p>
</div>